﻿using System;
using System.Web.Configuration;

namespace VioletDevelopmentLaboratory.Net.Web.Configuration
{
	public sealed class HttpModulesSectionManager : ConfigurationManagerBase
	{

		private HttpModulesSection section;

		public HttpModulesSectionManager()
		{
			this.section = (HttpModulesSection)base.GetConfigurationSection("system.web/httpModules");
		}

		public void AddModule(string name, string type)
		{
			this.section.Modules.Add(new HttpModuleAction(name, type));
			this.Save();
		}
		public void ModifyModule(int index, string name, string type)
		{
			this.section.Modules[index].Name = name;
			this.section.Modules[index].Type = type;
			this.Save();
		}
		public void RemoveModule(int index)
		{
			this.section.Modules.RemoveAt(index);
			this.Save();
		}
		public void ClearModules()
		{
			this.section.Modules.Clear();

			this.Save();
		}
		public HttpModuleAction GetModule(int index)
		{
			return this.section.Modules[index];
		}
		public HttpModuleActionCollection GetModules()
		{
			return this.section.Modules;
		}
	}
}